package manager

import "fmt"

// Gift 表示单个礼物的信息
type Gift struct {
	ID           string `json:"id"`
	Name         string `json:"name"`
	Value        int    `json:"value"`
	Score        int    `json:"score"`
	UpgradeLimit int    `json:"upgrade_limit"`
}

// GiftManager 管理所有礼物
type GiftManager struct {
	Gifts map[string]Gift
}

// 定义全局的gift列表
var giftList = []Gift{
	{ID: "1", Name: "点赞", Value: 0, Score: 1, UpgradeLimit: 999999},
	{ID: "2", Name: "加入粉丝团", Value: 10, Score: 75, UpgradeLimit: 999999},
	{ID: "3", Name: "粉丝团升级", Value: 100, Score: 750, UpgradeLimit: 999999},
	{ID: "4", Name: "666", Value: 0, Score: 2, UpgradeLimit: 999999},
	{ID: "n1/Dg1905sj1FyoBlQBvmbaDZFBNaKuKZH6zxHkv8Lg5x2cRfrKUTb8gzMs=", Name: "仙女棒", Value: 10, Score: 75, UpgradeLimit: 66},
	{ID: "eplFUy7i0B0fiv0Iym1MpOZa5XmUE8g/WUAyJ6Tc+UJJDpcs7pzclNOz/WM=", Name: "黄色仙女棒", Value: 10, Score: 75, UpgradeLimit: 66},
	{ID: "4I66OIE1HKWfM7PNvAHtAgYUSNlggSEgcpo3ai8GYQXAWqjrDuH8NtjsWEQ=", Name: "蓝色仙女棒", Value: 10, Score: 75, UpgradeLimit: 66},
	{ID: "XHS+QR5Cv0b9ydsZZ5mLkrhPtMTTdrLsgfWNU/QX2IfUy2P6dmDaRHJT+0U=", Name: "绿色仙女棒", Value: 10, Score: 75, UpgradeLimit: 66},
	{ID: "gs+95ujNzXXSCtLTv97fWgbApTQi0sqz1BULB+7w62g+v4sFxINvxOIrXCw=", Name: "紫色仙女棒", Value: 10, Score: 75, UpgradeLimit: 66},
	{ID: "28rYzVFNyXEXFC8HI+f/WG+I7a6lfl3OyZZjUS+CVuwCgYZrPrUdytGHu0c=", Name: "能力药丸", Value: 100, Score: 750, UpgradeLimit: 10},
	{ID: "fJs8HKQ0xlPRixn8JAUiL2gFRiLD9S6IFCFdvZODSnhyo9YN8q7xUuVVyZI=", Name: "魔法镜", Value: 190, Score: 1425, UpgradeLimit: 6},
	{ID: "PJ0FFeaDzXUreuUBZH6Hs+b56Jh0tQjrq0bIrrlZmv13GSAL9Q1hf59fjGk=", Name: "甜甜圈", Value: 520, Score: 3900, UpgradeLimit: 3},
	{ID: "IkkadLfz7O/a5UR45p/OOCCG6ewAWVbsuzR/Z+v1v76CBU+mTG/wPjqdpfg=", Name: "能量电池", Value: 990, Score: 7425, UpgradeLimit: 3},
	{ID: "gx7pmjQfhBaDOG2XkWI2peZ66YFWkCWRjZXpTqb23O/epru+sxWyTV/3Ufs=", Name: "爱的爆炸", Value: 1990, Score: 14925, UpgradeLimit: 3},
	{ID: "pGLo7HKNk1i4djkicmJXf6iWEyd+pfPBjbsHmd3WcX0Ierm2UdnRR7UINvI=", Name: "神秘空投", Value: 5200, Score: 39000, UpgradeLimit: 3},
	{ID: "P7zDZzpeO215SpUptB+aURb1+zC14UC9MY1+MHszKoF0p5gzYk8CNEbey60=", Name: "超能喷射", Value: 12000, Score: 90000, UpgradeLimit: 3},
}

// NewGiftManager 初始化GiftManager
func NewGiftManager() *GiftManager {
	giftMap := make(map[string]Gift)
	for _, gift := range giftList {
		giftMap[gift.ID] = gift
	}
	return &GiftManager{
		Gifts: giftMap,
	}
}

// GetGiftByID 根据ID获取对应的整个Gift信息
func (gm *GiftManager) GetGiftByID(id string) (*Gift, error) {
	gift, exists := gm.Gifts[id]
	if !exists {
		return nil, fmt.Errorf("can not find gift by gift id") // 或者可以返回一个包含零值的Gift，取决于你的需求
	}
	return &gift, nil
}
